package com.jy.rhin.infra.repo.document.submission.po;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.jy.rhin.domain.document.submission.entity.DocumentEntryVO;
import com.jy.rhin.infra.repo.document.submission.assembler.RhinCodeableAssembler;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * @author dhl
 */
@Data
@NoArgsConstructor
@TableName("t_document_entry")
public class DocumentEntryPO {

    public DocumentEntryPO(long submissionId, DocumentEntryVO entryVO) {
        this.id = entryVO.getId();
        this.submissionId = submissionId;
        this.title = entryVO.getTitle();
        this.uniqueId = entryVO.getUniqueId();
        this.patientId = entryVO.getPatientId();
        this.huanZheXm = entryVO.getHuanZheXm();
        this.zhengJianHm = entryVO.getZhengJianHm();
        this.formatCode = entryVO.getFormatCode();
        this.statusCode = entryVO.getStatusCode();
        this.serviceStopTime = entryVO.getServiceStopTime();
        this.homeCommunityId = entryVO.getHomeCommunityId();
        this.serviceStartTime = entryVO.getServiceStartTime();
        this.repositoryUniqueId = entryVO.getRepositoryUniqueId();
        this.classCode = RhinCodeableAssembler.getCodeText(DocumentEntryVO::getClassCode, entryVO);
        this.healthcareFacilityTypeCode = RhinCodeableAssembler.getCodeText(DocumentEntryVO::getHealthcareFacilityTypeCode, entryVO);
        this.practiceSettingCode = RhinCodeableAssembler.getCodeText(DocumentEntryVO::getPracticeSettingCode, entryVO);
        this.typeCode = RhinCodeableAssembler.getCodeText(DocumentEntryVO::getTypeCode, entryVO);
        this.creationTime = entryVO.getCreationTime();
        this.orgId = entryVO.getOrgId();
        this.orgName = entryVO.getOrgName();
        this.jsonText = entryVO.getJsonText();
    }

    @TableId
    private Long id;
    /**
     * 提交集id
     */
    @TableField("submission_id")
    private Long submissionId;
    /**
     * 文件格式
     */
    @TableField("format_code")
    private String formatCode;
    /**
     * 标题
     */
    @TableField("title")
    private String title;
    /**
     * 患者唯一标识
     */
    @TableField("patient_id")
    private String patientId;

    /**
     * 患者姓名
     */
    @TableField("huan_zhe_xm")
    private String huanZheXm;

    /**
     * 患者证件号码
     */
    @TableField("zheng_jian_hm")
    private String zhengJianHm;
    /**
     * 活动开始时间
     */
    @TableField("service_start_time")
    private Date serviceStartTime;
    /**
     * 活动结束时间
     */
    @TableField("service_stop_time")
    private Date serviceStopTime;
    /**
     * 文档最早创建时间
     */
    @TableField("creation_time")
    private Date creationTime;
    /**
     * 可用状态;固定值为 New
     */
    @TableField("status_code")
    private String statusCode;
    /**
     * 唯一标识符
     */
    @TableField("unique_id")
    private String uniqueId;
    /**
     * 存储文档的文档存储库唯一标识符
     */
    @TableField("repository_unique_id")
    private String repositoryUniqueId;
    /**
     * 文档管理域标识
     */
    @TableField("home_community_id")
    private String homeCommunityId;

    /**
     * 文档的粗粒度分类
     */
    @TableField("class_code")
    private String classCode;
    /**
     * 就诊机构类型代码
     */
    @TableField("healthcare_facility_type_code")
    private String healthcareFacilityTypeCode;
    /**
     * 就诊机构专业分类代码
     */
    @TableField("practice_setting_code")
    private String practiceSettingCode;
    /**
     * 就诊活动的细粒度分类
     */
    @TableField("type_code")
    private String typeCode;
    /**
     * 医疗机构id
     */
    @TableField("org_id")
    private String orgId;
    /**
     * 医疗机构名称
     */
    @TableField("org_name")
    private String orgName;
    /**
     * 文件条目json串
     */
    @TableField("json_text")
    private String jsonText;

}
